<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * HTML View class for the HelloWorld Component
 */
class ShopViewEmployer extends JView
{
	protected $state = null;
	protected $items = null;
	protected $path_img = null;
	// Overwriting JView display method
	function display($tpl = null) 
	{
		// Assign data to the view
		$id = JRequest::getVar('id');
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('*');
		$query->from('#__shop_employer');
		$query->where('id = '.$id);
		$db->setQuery((string) $query);
		$row = $db->loadObject();
		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		$this->item = $row;
		// Display the view
		parent::display($tpl);
	}
	
	/**
	*	Get Number Word in longtext
	*
	**/
	public function getText(&$longText,$numWords){
            $ret="";
            if($longText!=""){
                $longText=trim($longText);
                $longText=stripslashes($longText);
                $longText=strip_tags($longText);
				$arrayText=explode(" ",$longText);
                if(count($arrayText)>$numWords){
                    for($i=0;$i<$numWords;$i++){
                        $ret.=$arrayText[$i]." ";
                    }
                    $longText=trim($ret)."..";
                    return $longText;
                }
                else{
                    return $longText;
                }
            }
     }
	/*
		get company name
	**/
	public function getCompanyName($id)
	{
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('*');
		$query->from('#__shop_product');
		$query->where("id = $id");
		$db->setQuery((string)$query);
		return $db->loadObject();
	}
	/**
	*	get Addess
	**/
	public function getAddress($id)
	{
		$db = JFactory::getDBO();
		$query = "select * 
				from #__shop_address as t1
				where t1.id = $id
				union 
				select t2.* 
				from r81kq_shop_address as t2, r81kq_shop_address as t3
				where t3.id = $id and t2.id = t3.parent_id";
		$db->setQuery($query);
		return $db->loadObjectList();
		
	}
}
